package xxd
import grails.util.BuildSettings
import org.springframework.core.io.ClassPathResource
import org.springframework.core.io.support.PropertiesLoaderUtils
import sysUtil.MyBatisUtil
import sysUtil.SysCommUtil


class SpecialTest01Controller {


    def buildSettings = BuildSettings.newInstance()
    def index() {
        def dir = grailsApplication.getMainContext().servletContext.getRealPath("")
        println "${buildSettings.userHome}"
        new File("${buildSettings.userHome}\\dataFile").mkdirs()
        render "grailsHome:${buildSettings.baseDir}"
    }



    /**
     * B方式，通过列来索引行
     */

    def sysDBUtilService



    def c(){
        println grailsApplication.config
        //读取配置文件
        def property = PropertiesLoaderUtils.loadProperties(new ClassPathResource("dataSource.properties"))
        render   grailsApplication.config
    }


    //1.注入service:myBatisUtilService
    //2.在mapper文件中配置sql
    //3.调用myBatisUtilService.getSqlSession()，执行相应SQL

    def d(){
        def sqlsession = MyBatisUtil.getSqlSession("OracleDevelopment")
        List<Map>  list =  sqlsession.selectList("XdSysAdminMapper.testEchart1")
        // println list
        def result = SysCommUtil.listPivot(list,"TYPE_FLAG","VALUE")
        println result
        MyBatisUtil.commitAndCloseSession(sqlsession)
    }
}
